﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataObject.DataAccess;

public partial class Pages_Operators_Ascx_ProgramPopup : System.Web.UI.UserControl
{
    private readonly IList<int> dates = new List<int>(new int[] { 1, 21, 31, 2, 22, 3, 23 });

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            // Load Service
            foreach (var item in ServiceDAO.CreateInstant().GetAll())
            {
                var listItem = new ListItem
                {
                    Text = item.ServiceCode,
                    Value = item.ServiceID.ToString()
                };
                listItem.Attributes.Add("ServiceName", item.ServiceName);
                this.ddlServiceCodeInput.Items.Add(listItem);
            }

            for (int i = 0; i < define.Services.Length; i++)
            {
                this.ddlServiceTypeInput.Items.Add(new ListItem
                {
                    Value = "" + i,
                    Text = define.Services[i],
                    Selected = define.Services[i] == "Shared"
                });
            }

            int length = 15, idx;
            string seq = String.Empty;

            for (int i = 0; i < length; i++)
            {
                idx = dates.IndexOf(i + 1);
                if (idx < 0)
                    seq = "th";
                else if (idx < 3)
                    seq = "st";
                else if (idx < 5)
                    seq = "nd";
                else
                    seq = "rd";
                this.ddlDayOfRouteInput.Items.Add(new ListItem
                {
                    Value = i.ToString(),
                    Text = String.Format("{0}{1}", i + 1, seq)
                });
            }
        }
    }
}
